<template>
  <el-form-item label="操作">
    <el-button size="small" plain type="primary" :loading="loading" @click="onUnAlaemClick">
      解除报警状态
    </el-button>
  </el-form-item>
</template>
<script setup lang="ts">
import DeviceAPI from "@/api/device";

const loading = ref(false);

defineOptions({
  name: "UserDeviceAlaemSmokeBtns",
});

const props = defineProps({
  sn: {
    type: [String],
    default: "",
  },
});

/**
 * @description 解除报警状态
 */
function onUnAlaemClick() {
  ElMessageBox.confirm("确定解除报警状态吗？", "提示", {
    confirmButtonText: "确定",
    cancelButtonText: "取消",
    type: "warning",
  }).then(() => {
    loading.value = true;
    DeviceAPI.removeWaring(props.sn)
      .then(() => {
        ElMessage.success("操作成功");
      })
      .finally(() => (loading.value = false));
  });
}
</script>
